<?php

namespace backend\jobs;

use backend\models\YueJuan;

/**
 * Class Pdf2PngJob.
 */
class Pdf2PngJob extends \yii\base\BaseObject implements \yii\queue\RetryableJobInterface
{
    public $url;

    public $pdf_id;

    public $path;

    public $filename;

    public $filename_random;

    public $title;

    public $user_id;

    /**
     * @inheritdoc
     */
    public function execute($queue)
    {
        $params = ['pdf_id' => $this->pdf_id, 'path' => $this->path, 'filename' => $this->filename, 'filename_random' => $this->filename_random, 'title' => $this->title, 'user_id' => $this->user_id];
        $cmd = $this->url . '?' . http_build_query($params);
//        exec('curl -s "' . $cmd . '"');
        file_get_contents($cmd);
    }

    /**
     * @inheritdoc
     */
    public function getTtr()
    {
        return 60 * 60;
    }

    /**
     * @inheritdoc
     */
    public function canRetry($attempt, $error)
    {
        return $attempt = 0;
    }
}
